package com.zyz.sunliky.quartz.jobs;

import com.zyz.sunliky.quartz.ScheduledJob;
import com.zyz.sunliky.service.SupplierService;
import jakarta.annotation.Resource;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * 同步采购供应商信息
 */
@Component
public class SupplierJob extends ScheduledJob {
    @Resource
    SupplierService supplierService;

    @Override
  //  每两个小时执行一次
    public String getCron() {
        return "0 0 */1 * * ?";
    }
//    public String getCron() {
//        return "0 */5 * * * ?";
//    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            Date now = new Date();
            System.out.println("供应商信息同步开始---" +now);
            supplierService.saveSupplier();
            System.out.println("供应商信息同步结束---" +now);
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
